﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class togetherbuy : System.Web.UI.Page
{
    protected List<Model.LotteryChipped> userbuy = null;
    protected List<Model.Lottery> arlist = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int totalCount2 = 0;
            arlist = BLL.Lottery.GetPageList_Where(0, int.MaxValue, 0, out  totalCount2);
            this.qsddl.DataSource = arlist;
            this.qsddl.DataValueField = "id";
            this.qsddl.DataTextField = "Name";
            this.qsddl.DataBind();
            qsddl.Items.Insert(0, new ListItem("--请选择彩种--", "0"));    

            bindtable();
        }
    }
    protected void qsddl_SelectedIndexChanged(object sender, EventArgs e)
    {
        bindtable();
    }
    private void bindtable()
    {
        PagedDataSource pds = new PagedDataSource();
        string sql = "";
        if (int.Parse(qsddl.SelectedValue.ToString()) > 0)
        {
            sql = " and LotteryType=" + int.Parse(qsddl.SelectedValue.ToString());
        }
        if (int.Parse(isManDDl.SelectedValue.ToString()) == 0)
        {
            sql += " and (LotteryJD <=100)";
        }
        else if (int.Parse(isManDDl.SelectedValue.ToString()) == 1)
        {
            sql += " and LotteryJD <100";
        }
        else if (int.Parse(isManDDl.SelectedValue.ToString()) == 2)
        {
            sql += " and (LotteryJD between 50 and 100)";
        }
        else if (int.Parse(isManDDl.SelectedValue.ToString()) == 3)
        {
            sql += " and (LotteryJD >=90)";
        }
        if (int.Parse(jineDDl.SelectedValue.ToString()) == 0)
        {
            sql += " and LotteryMoney>0";
        }
        else if (int.Parse(jineDDl.SelectedValue.ToString()) == 1)
        {
            sql += " and LotteryMoney  <100";
        }
        else if (int.Parse(jineDDl.SelectedValue.ToString()) == 2)
        {
            sql += " and  (LotteryMoney  between 100 and 500)";
        }
        else if (int.Parse(jineDDl.SelectedValue.ToString()) == 3)
        {
            sql += " and  (LotteryMoney  between 500 and 1000)";
        }
        else if (int.Parse(jineDDl.SelectedValue.ToString()) == 4)
        {
            sql += " and LotteryMoney >1000";
        }
        int totalCount4 = 0;
        userbuy = BLL.LotteryChipped.GetPageListBysql(this.AspNetPager1.CurrentPageIndex - 1, this.AspNetPager1.PageSize, sql, out  totalCount4); 
        if (userbuy != null && userbuy.Count > 0)
        {

            AspNetPager1.RecordCount = totalCount4;
            pds.AllowPaging = true;
            pds.PageSize = AspNetPager1.PageSize;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;

        }
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bindtable();
    }
    public string SelectName(object Uid)
    {
        Model.CMember cm = BLL.CMember.GetModel(Convert.ToInt32(Uid));
        if (cm != null)
        {
            return cm.nickname;//用户真实姓名
        }
        else
        {
            return "";
        }
    }
    protected void isManDDl_SelectedIndexChanged(object sender, EventArgs e)
    {
        bindtable();
    }
    protected void jineDDl_SelectedIndexChanged(object sender, EventArgs e)
    {
        bindtable();
    }
}